package demo5;

/**
 * @program: java-generic
 * @description: 类型通配符
 * @author: bjc
 * @create: 2021-08-15 15:43
 */
public class Main {

    public static void main(String[] args) {
        Box<Number> box1 = new Box<>();
        box1.setFirst(100);
        showBox(box1);

        Box<Integer> box2 = new Box<>();
        box2.setFirst(200);
        showBox(box2);
    }

    /**
     * 上限通配符
     * @param box
     */
    public static void showBox(Box<? extends Number> box){
        Number first = box.getFirst();
        System.out.println(first);
    }
}
